<template>
  <div class="kuai1">
    <backzj :mssg='aaa.tlte'/>
    <ssfl v-show="aaa.showif==1"/>
    <div :class="{'sdgs1':aaa.showif==0 || aaa.showif==2,'sdgs':aaa.showif==1}">
    <!-- 轮播区域 -->
      <div class="banner" v-show="aaa.showif==2">
        <mt-swipe class="abnnimg">
          <mt-swipe-item>
            <img :src="SMDataURL+'/images/spspa2.png'"></img>
          </mt-swipe-item>
          <mt-swipe-item>
            <img :src="SMDataURL+'/images/pplb1.png'"></img>
          </mt-swipe-item>
          <mt-swipe-item>
            <img :src="SMDataURL+'/images/pplb2.png'"></img>
          </mt-swipe-item>
        </mt-swipe>
      </div>
    <!-- 轮播区域 -->
    <!-- 签到规则区域 -->
      <div class="qianna" v-show="aaa.showif==2">
        <p>签到红包</p>
        <div class="dsjfk" @click="gze">
          <p>新手必读&nbsp;&nbsp;&nbsp;▼</p>
          <div class="dsvvs" v-show="gzee">
            <p>拼团需知</p>
            <p>1元拼团</p>
            <p>签到红包</p>
            <p>拉新红包及返佣</p>
          </div>
        </div>
      </div>
    <!-- 签到规则区域 -->
    <!-- 商品区域 -->
       <div class="xpt" v-for="(item,index) in listdata" :key='index' @click="toxqq(item)">
            <div class="xtop">
                <div class="xleft">
                    <div class="ximg">
                        <span class="xtuan">{{item.totalNum}}人团</span>
                    </div>
                </div>
                <div class="xjs"><span class="cored">{{item.successNum}}</span>人拼中商品,<span class="cored">{{item.lotteryNum}}</span>人各得<span class="cored">￥{{item.couponMoney}}</span></div>
                <div class="xdiqi">第{{item.periods}}期</div>
            </div>
            <div class="xbtop">
                <div class="xbleft">
                    <img :src="item.photos[0]">
                </div>
                <div class="xbright">
                    <div class="xbjs">{{item.productName}}</div>
                    <div class="xbptt">
                        <p class="xbjq">拼团价<span class="orange">￥{{item.spellGroupPrice}}</span></p >
                        <p class="xbjq">单品价<span class="xbsc">￥{{item.price}}</span></p >
                    </div>
                    <div class="bjdu">
                        <div class="jindt">
                            <mt-progress :value="20" :bar-height="6"></mt-progress>
                        </div>
                        <div class="jdtsz">{{item.totalNum>item.cnt?'还差'+(item.totalNum-item.cnt)+'人':'已拼满'}}</div>
                    </div>
                    <div class="xrhd" v-if="item.endDate">{{item.endDate!=''?'截止:'+item.endDate:''}}</div>
                </div>
            </div>
        </div>
        <!-- 商品区域 -->
    </div>
    <!-- 规则区域 -->
      <div class="zhezhao" v-show="0"></div>
      <div class="tanc" v-if="0">

      </div>
    <!-- 规则区域 -->
  </div>
</template>

<script>
import Backzj from "../components/backzj.vue";
import ssfl from "../components/ssfl.vue";
import { getlist } from "../api/spell.js"; // 导入api
export default {
  components: { ssfl, Backzj },
  data() {
    return {
      DataURL: "https://e.amjhome.com/baojiayou/tts_upload",
      SMDataURL: "https://bjy.51yunkeyi.com/baojiayou/tts_upload",
      arr: [1, 1, 1, 1, 1, 1],
      aaa: "",
      gzee: false,
      listdata: "",
    };
  },
  methods: {
    gze() {
      this.gzee = !this.gzee;
    },
    toxqq(item) {
      this.$router.push({
        name:'spxiangq',
         params: {
            info:item
          }
      });
    },
  },
  created() {
    console.log(this.$route.query, "777777");
    if (this.$route.query.type == "0") {
      getlist({
        writeoff: 0,
        type: "0,1,2",
        companyPId: -7,
      }).then((res) => {
        console.log("XXX区的数据", res.data);
        let aaa = res.data;
        aaa.forEach((item) => {
          item.photos = item.photos.split(",");
        });
        this.listdata = aaa;
      });
    }
    if (this.$route.query.type == "1") {
      getlist({
        writeoff: 0,
        type: "0,1",
        num: "2,3",
        companyPId: -7,
      }).then((res) => {
        console.log("XXX区的数据", res.data);
        let aaa = res.data;
        aaa.forEach((item) => {
          item.photos = item.photos.split(",");
        });
        this.listdata = aaa;
      });
    }
    if (this.$route.query.type == "2") {
      getlist({
        writeoff: 0,
        type: "2,3",
        companyPId: -7,
      }).then((res) => {
        console.log("XXX区的数据", res.data);
        let aaa = res.data;
        aaa.forEach((item) => {
          item.photos = item.photos.split(",");
        });
        this.listdata = aaa;
      });
    }
  },
  mounted() {
    var that = this;
    if (that.$route.query) {
      that.aaa = that.$route.query;
    }
  },
};
</script>

<style scoped>
.sdgs1 {
  width: 100%;
  margin-top: 40px;
}
.sdgs {
  width: 100%;
  height: calc(100vh - 156px);
  overflow-y: auto;
}
.sdgs1 {
  width: 100%;
  margin-top: 40px;
}
/* 轮播区域 */
.banner {
  margin: 4px 0;
}
.abnnimg {
  height: 150px;
  padding: 0 10px;
  overflow: hidden;
}
.abnnimg img {
  width: 100%;
  height: 150px;
}
/* 轮播区域 */
/* 签到规则区域 */
.qianna {
  justify-content: space-between;
  display: flex;
  align-items: center;
  height: 25px;
  padding: 0 10px;
}
.dsjfk {
  width: 38%;
  text-align: center;
  position: relative;
  border: 1px solid rgba(220, 220, 220, 0.911);
  border-radius: 4px;
}
.dsvvs {
  width: 100%;
  position: absolute;
  top: 23px;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(170, 167, 167, 0.897);
  z-index: 200;
  color: white;
  border-radius: 4px;
  box-sizing: border-box;
}
.dsvvs p {
  margin: 4px 0;
}
/* 签到规则区域 */
/* 商品区域 */
.xpt {
  display: flex;
  flex-direction: column;
  margin: 4px 0 16px 0;
}
.xtop {
  width: 100%;
  display: flex;
  align-items: center;
  background: #eee;
  justify-content: space-between;
  margin: 0 auto;
  border-radius: 4px;
  box-sizing: border-box;
  padding: 0 10px;
}
.xleft {
  display: flex;
  align-items: center;
  /* margin-left: 10rpx; */
}
.ximg {
  width: 88px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  background: #f8df95;
  border-radius: 6px 50px 50px 6px;
}
.ximg img {
  max-width: 100%;
  max-height: 100%;
}
.xtuan {
  margin-right: 12px;
}
.xjs {
  margin-left: 5px;
}
.cored {
  color: #ff3333;
}
.xbtop {
  display: flex;
  align-items: center;
  padding: 0 10px;
  margin-top: 6px;
}
.xbleft {
  width: 110px;
  height: 110px;
  border: 1px solid gainsboro;
  border-radius: 4px;
  margin-right: 10px;
}
.xbleft img {
  max-width: 100%;
  max-height: 100%;
}
.xbright {
  width: 65%;
  /* border: 1rpx solid red; */
  display: flex;
  flex-direction: column;
}
.xbjs {
  font-weight: 700;
  color: #333333;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.xbptt {
  display: flex;
  align-items: center;
  margin: 3px 0;
}
.xbjq {
  font-size: 15px;
  font-weight: 400;
  margin-right: 15px;
}
.orange {
  color: #f07244;
}
.xbsc {
  font-size: 15px;
  font-weight: 400;
  text-decoration: line-through;
  color: #999999;
}
.bjdu {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.jindt {
  width: 70%;
}
.jindt /deep/ .mt-progress-runway {
  border-radius: 4px;
}
.jindt /deep/ .mt-progress-progress {
  background: #f4793b;
  border-radius: 4px;
}
.jdtsz {
  color: #666;
  font-size: 14px;
}
.xrhd {
  font-size: 12px;
  font-weight: 700;
}
/* 商品区域 */
/* 规则区域 */
.tanc {
  width: 100%;
  height: 80%;
  background: white;
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 200;
  border-radius: 8px 8px 0 0;
  box-sizing: border-box;
  padding: 10px;
}
/* 规则区域 */
</style>